package com.lwl.dubbo.serviceImpl;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import javax.annotation.Resource;

import java.util.Set;

import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lwl.dubbo.bean.Point;
import com.lwl.dubbo.dao.PointMapper;
import com.lwl.dubbo.service.PointService;

/**
 * 农合经办点service
 * @author 
 *
 */
@Service("pointService")
public class PointServiceImpl implements PointService{

	@Resource(name="pointMapper")
	private PointMapper pointMapper;
	/**
	 * 网点经办点Mapper
	 */
	/*@Autowired
	private PointMapper pointMapper;
	*/
	/**
	 * 创建SqlSession的工厂
	 */
	@Autowired
	private SqlSessionFactory sqlSessionFactory;
	
	/**农合经办点
	 * @param id
	 * @return
	 */
	@Transactional
	@Override
	public boolean updatePoint(Point point) {
		System.out.println("pointMapper.updateByPrimaryKeySelective(point)"+pointMapper.updateByPrimaryKeySelective(point));
		System.out.println("updateByPrimaryKey(Point)"+pointMapper.updateByPrimaryKey(point));
		return pointMapper.updateByPrimaryKeySelective(point)> 0;
		/*return pointMapper.updateByPrimaryKey(point) > 0;*/
		
	}
	
	/**
	 * 逐个添加农合经办点
	 * @param Point
	 * @return
	 */
	@Transactional
	@Override
	public boolean addPoint(Point point) {
		/*return PointMapper.insert(Point) > 0;*/
		return pointMapper.insertSelective(point) > 0;
	}
	
	/**
	 * 模糊查询
	 * @return
	 */
	@Transactional
	@Override
	public List<Point> findByKeyword(Point point) {
		return pointMapper.selectByKeyWord(point);
	}
	
	/**
	 * 按农合经办点id查询
	 * @param userid
	 * @return
	 */
	@Transactional
	@Override
	public Point findbyId(Integer id) {
		
		return pointMapper.selectByPrimaryKey(id);
	}

	/**
	 * 按农合经办点id删除
	 * @param userid
	 * @return
	 */
	@Transactional
	@Override
	public int deletePoint(Integer id) {
		return pointMapper.deleteByPrimaryKey(id);
	}

}
